<template>
	<view>
		<view class=" bg text-white radius u-skeleton-fillet">
			<!-- <view class="flex align-center justify-between">
				<view class="text-lg">用户评价</view>
				<view>
					<text class="text-sm margin-right-xs">查看更多</text>
					<image src="../../static/images/my/right_icon.png" style="width: 12upx;height: 20upx;"></image>
				</view>
			</view> -->
			<view class=" padding " v-for="(item,index) in commentList" :key="index">
				<view class="flex justify-between">
					<u-avatar :src="item.avatar" size="48"></u-avatar>
					<view class="flex-sub margin-left-sm" style="line-height: 46upx;">{{item.userName}}
					</view>
					<view class="flex">
						<u-icon v-for="ite in item.satisfactionFlag" :key='ite' color="#2087fe" name="star-fill">
						</u-icon>
					</view>
				</view>
				<view class="margin-top-sm">{{item.evaluateMessage}}</view>
				<view class="margin-top-xs flex flex-wrap">
					<view class="margin-right-xs margin-bottom-xs" v-for="(ite,ind) in item.evaluateImg" :key="ind"
						@click="saveImg(item.evaluateImg,ind)">
						<image :src="ite" mode="aspectFill" style="width: 200rpx;height: 200rpx;"></image>
					</view>
				</view>
			</view>
		</view>
		<empty v-if="commentList.length == 0"></empty>
	</view>
</template>

<script>
	import empty from '../../components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				commentList: [],
				page: 1,
				limit: 10,
				id: ""
			}
		},
		onLoad(option) {
			uni.showLoading({
				title: '加载中'
			})
			if (option.id) {
				this.id = option.id
				this.getOrderComment()
			}
		},
		onShow() {

		},
		methods: {
			// 评论
			getOrderComment() {
				this.$Request.get("/app/evaluate/getUserEvaluate", {
					evaluateType: 2,
					orderTakingId: this.id,
					page: this.page,
					limit: this.limit
				}).then(res => {
					if (res.code == 0) {
						for (var i = 0; i < res.data.records.length; i++) {
							res.data.records[i].evaluateImg = res.data.records[i].evaluateImg.split(',')
						}
						if (this.page == 1) {
							this.commentList = res.data.records
						} else {
							this.commentList = [...this.commentList, ...res.data.records]
						}
						uni.hideLoading();
						uni.stopPullDownRefresh();
					}
				});
			},
			// 查看图片
			saveImg(imgs, index) {
				// console.log(imgs)
				let that = this;
				let imgArr = imgs
				// imgArr.push(imgs);
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: imgArr[index]
				});
			},
		},
		onReachBottom: function() {
			this.page = this.page + 1;
			this.getOrderComment()
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.getOrderComment()
		},
	}
</script>

<style>
	page {
		background-color: #F7F7F7;
	}

	.bg {
		background: #ffffff;
	}
</style>